<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TagM: RTOS::mailbox&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">TagM
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="class_r_t_o_s.html">RTOS</a></li><li class="navelem"><a class="el" href="class_r_t_o_s_1_1mailbox.html">mailbox</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">RTOS::mailbox&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>synchronous handling over of a data item  
 <a href="class_r_t_o_s_1_1mailbox.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RTOS::mailbox&lt; T &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_r_t_o_s_1_1mailbox.png" usemap="#RTOS::mailbox&lt; T &gt;_map" alt=""/>
  <map id="RTOS::mailbox&lt; T &gt;_map" name="RTOS::mailbox&lt; T &gt;_map">
<area href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class." alt="RTOS::mailbox_base" shape="rect" coords="0,0,127,24"/>
</map>
 </div></div>

<p><a href="class_r_t_o_s_1_1mailbox-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aaee470ef9fc6627e848e45ca353415ff"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mailbox.html#aaee470ef9fc6627e848e45ca353415ff">mailbox</a> (const char *name=&quot;&quot;)</td></tr>
<tr class="memdesc:aaee470ef9fc6627e848e45ca353415ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">construtor, specify mutex name  <a href="#aaee470ef9fc6627e848e45ca353415ff"></a><br/></td></tr>
<tr class="memitem:ad140965320e8b42ca16a5d288858f70d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mailbox.html#ad140965320e8b42ca16a5d288858f70d">write</a> (const T item)</td></tr>
<tr class="memdesc:ad140965320e8b42ca16a5d288858f70d"><td class="mdescLeft">&#160;</td><td class="mdescRight">write an item into the mailbox  <a href="#ad140965320e8b42ca16a5d288858f70d"></a><br/></td></tr>
<tr class="memitem:af2bc862b64929b5ec34afa4dec0ed720"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mailbox.html#af2bc862b64929b5ec34afa4dec0ed720">read</a> (void)</td></tr>
<tr class="memdesc:af2bc862b64929b5ec34afa4dec0ed720"><td class="mdescLeft">&#160;</td><td class="mdescRight">read a value from the mailbox  <a href="#af2bc862b64929b5ec34afa4dec0ed720"></a><br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_methods_class_r_t_o_s_1_1mailbox__base"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_class_r_t_o_s_1_1mailbox__base')"><img src="closed.png" alt="-"/>&nbsp;Private Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1mailbox__base.html">RTOS::mailbox_base</a></td></tr>
<tr class="memitem:a935d65de435dfbb9d567b461bf619259 inherit pub_methods_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a935d65de435dfbb9d567b461bf619259"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>mailbox_base</b> (const char *name)</td></tr>
<tr class="memitem:ac165beaf90a7c0de8434cb3158114525 inherit pub_methods_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac165beaf90a7c0de8434cb3158114525"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>print</b> (std::ostream &amp;s, bool header=true) const </td></tr>
<tr class="inherit_header pub_attribs_class_r_t_o_s_1_1mailbox__base"><td colspan="2" onclick="javascript:toggleInherit('pub_attribs_class_r_t_o_s_1_1mailbox__base')"><img src="closed.png" alt="-"/>&nbsp;Private Attributes inherited from <a class="el" href="class_r_t_o_s_1_1mailbox__base.html">RTOS::mailbox_base</a></td></tr>
<tr class="memitem:a43dbd1a8a4441c083c6098da9ff2194a inherit pub_attribs_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a43dbd1a8a4441c083c6098da9ff2194a"></a>
<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>client</b></td></tr>
<tr class="memitem:a133b02c5f2c1dcff4c9346f9455ef351 inherit pub_attribs_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a133b02c5f2c1dcff4c9346f9455ef351"></a>
const char *&#160;</td><td class="memItemRight" valign="bottom"><b>mailbox_name</b></td></tr>
<tr class="memitem:ad516d6ec92cf782c12a0e4b09d232b89 inherit pub_attribs_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad516d6ec92cf782c12a0e4b09d232b89"></a>
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><b>writes</b></td></tr>
<tr class="memitem:a7dc6ac147e3abbd3a3d77ab97812bada inherit pub_attribs_class_r_t_o_s_1_1mailbox__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7dc6ac147e3abbd3a3d77ab97812bada"></a>
<a class="el" href="class_r_t_o_s_1_1mailbox__base.html">mailbox_base</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>next_mailbox</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;class T&gt;<br/>
class RTOS::mailbox&lt; T &gt;</h3>

<p>synchronous handling over of a data item </p>
<pre class="fragment">  A mailbox is a template class synchronization mechanism. 
  A single value can be written to the mailbox. 
  Another task can read the value from the mailbox. 
  The read and write calls each wait on each other before they 
  are allowed to proceed.
  A mailbox is not created for a particular task, 
  and it is not a waitable.

  Initially a mailbox is empty. 
  The \ref write() operation bloks the calling task until 
  the mailbox is empty, then writes to the mailbox, and blocks. 
  The \ref read() operation blocks the calling task until 
  there is a value in the mailbox. 
  Then it reads the value, unblocks the task that wrote to 
  the mailbox, and returns. 

  The example below uses a mailbox to buffer writing cout 
  data to the UART. The function that writes each cout character 
  writes it to a mailbox, which is read by the  UART task. 
  This task waits 2 MS after each write to the UART, 
  to avoid busy waiting.

  @code 
</pre><p> TBW  </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aaee470ef9fc6627e848e45ca353415ff"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_r_t_o_s_1_1mailbox.html">RTOS::mailbox</a>&lt; T &gt;::<a class="el" href="class_r_t_o_s_1_1mailbox.html">mailbox</a> </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em> = <code>&quot;&quot;</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>construtor, specify mutex name </p>
<p>Create a mutex. The mutex is initially set. The template argument T must be a class that has a non-arguments constructor and supports assignment. </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="af2bc862b64929b5ec34afa4dec0ed720"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T <a class="el" href="class_r_t_o_s_1_1mailbox.html">RTOS::mailbox</a>&lt; T &gt;::read </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>read a value from the mailbox </p>
<p>If one or more tasks are waiting for the mutex the first one is released, and it now owns the mutex. Otherwise, if the mutex is cleared it is now set.</p>
<p>It is an error for a task to call signal() on a mutex that it does not own (that it did not call wait() on). After the signal the task no longer owns the mutex. </p>

</div>
</div>
<a class="anchor" id="ad140965320e8b42ca16a5d288858f70d"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_r_t_o_s_1_1mailbox.html">RTOS::mailbox</a>&lt; T &gt;::write </td>
          <td>(</td>
          <td class="paramtype">const T&#160;</td>
          <td class="paramname"><em>item</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>write an item into the mailbox </p>
<p>If the mutex was set it it is now cleared, and the calling task owns the mutex.</p>
<p>Otherwise the current task waits (is halted) until the owning task calls signal() on the same mutex. The signal() calls will release the tasks in the order of their wait() calls. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 27 2012 11:07:15 for TagM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
